<%-- 
    Document   : FrUsuario
    Created on : 20-10-2013, 04:53:08 PM
    Author     : moises sepulveda
--%>


<%@page import="libreriaTicket.dao.DaoRegion"%>
<%@page import="libreriaTicket.entity.Region"%>
<%@page import="java.util.ArrayList"%>
<%@page import="libreriaTicket.entity.Usuario"%>
<%@page import="libreriaTicket.entity.Comuna"%>
<%@page import="libreriaTicket.dao.DaoUsuario"%>
<%
    String usuario = "";
    String password = "";
    String rut = "";
    String dv = "";
    String apeMaterno = "";
    String apePaterno = "";
    String comuna = "";
    String direccion = "";
    String nombre = "";

%>


<%
    if (request.getParameter("txtRut") != null) {
        DaoUsuario.sqlInsert(new Usuario(usuario, password, nombre, apePaterno, apeMaterno, direccion, new Comuna(Integer.parseInt(comuna)), Integer.parseInt(rut), dv.charAt(0)));
    }

%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Ingreso de Usuario</title>

        <link href="publico/css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
        <link href="publico/css/bootstrap-select.min.css" rel="stylesheet" media="screen">
        <link href="publico/css/bootstrap.css" rel="stylesheet" media="screen">
        <script src="publico/script/jquery.js" type="text/javascript"></script>
        <script src="js/bootstrap.min.js" type="text/javascript"></script>
        <script src="js/bootstrap-select.min.js" type="text/javascript"></script>
        <script src="publico/script/ajax.js" type="text/javascript"></script>
        <script src="publico/script/usuario.js" type="text/javascript"></script>
</head>
<body>
    <header style="min-height: 100px;"><jsp:include page="menu.html" flush="true" /></header>
    <div class="container" style="width: 750px">

        <form class="form-signin">
            <h2 class="form-signin-heading">Nuevo Usuario</h2>
            <label>Nombre de Usuario</label>
            <input type="text" class="form-control" value="asdf" name="txtUsuarioR" id="txtUsuarioR" placeholder="Ingrese nombre de usuario"/>
            <label>Contraseña</label>
            <input type="password" class="form-control" name="txtPass" id="txtPass" placeholder="Ingrese su contraseña" />
            <label>Confirme Contraseña</label>
            <input type="password" class="form-control" name="txtPass2" id="txtPass2" placeholder="confirme su contraseña" />
            <form class="form-horizontal" >
                <div class="form-group" style="padding-bottom: 55px; padding-right: 50px">
                    <div class="col-xs-5" >
                        <label>Rut</label>
                        <input type="text" class="form-control" name="txtRut" id="txtRut" placeholder="Ingrese rut" required >
                    </div>
                    <div  class="col-xs-3">
                        <label>Cod. Verificador</label>
                        <input type="text" class="form-control" name="txtDv" id="txtDv" placeholder="CV" required>
                    </div>
                </div>
            </form>
            <label>Nombres</label>
            <input type="text" class="form-control" name="txtNombre" id="txtNombre" placeholder="Ingrese sus nombres" required>
            <label>Apellido Materno</label>
            <input type="text" class="form-control" name="txtApellidoP" id="txtApellidoP" placeholder="Ingrese su apellido Paterno" required>
            <label>Apellido Materno</label>
            <input type="text" class="form-control" name="txtApellidoM" id="txtApellidoM" placeholder="Ingrese su apellido Materno" required>
            <div class="form-group">
                <label>Region</label>
                <select  class ="selectpicker" name="cboRegion" id="cboRegion">
                <%
                    ArrayList<Region> regiones = DaoRegion.sqlSelectAll();
                    for (Region region : regiones) {
                        out.write("<option value=\"" + region.getIdRegion() + "\">");
                        out.write(region.getDescripcion());
                        out.write("</option>");
                    }
                %>
                </select>
                <label>Comuna</label>
                <select name="cboComuna" id="cboComuna">
                    <option value="0">Seleccionar</option>
                </select>
            </div>
            <label>Direccion</label>
            <input type="text" class="form-control" name="txtCalle" id="txtCalle" placeholder="Ingrese direccion" required>

            <button class="btn btn-lg btn-primary btn-block" id="btnRegistrar" type="submit">Enviar</button>

        </form>

    </div>

</body>
</html>
